﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Threading;
using PhoneApp1.Model;
namespace PhoneApp1
{
    public partial class PivotPage1 : PhoneApplicationPage
    {
        DateTime mTime;
        public PivotPage1()
        {
            this.DataContext = App.IncomeView;
            InitializeComponent();
            mTime = new DateTime();
            mTime = DateTime.Now;
            mTodayText.Text = mTime.ToLocalTime().Day.ToString() + "/" 
                            + mTime.ToLocalTime().Month.ToString() + "/" 
                            + mTime.ToLocalTime().Year.ToString();
            DispatcherTimer tmr = new DispatcherTimer();
            tmr.Interval = TimeSpan.FromDays(1);
            tmr.Start(); 
            tmr.Tick += OnTimeTick;
        }

        private void OnTimeTick(object sender, EventArgs e)
        {
            mTodayText.Text = mTime.ToLocalTime().Day.ToString() + "/" 
                            + mTime.ToLocalTime().Month.ToString() + "/" 
                            + mTime.ToLocalTime().Year.ToString();
        }

        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/NewIncome.xaml", UriKind.Relative));
        }
    }
}